//package com.xuelang.pipeline.artifact.app.resource.impl;
//
//import com.xuelang.pipeline.artifact.app.resource.SysNgacService;
//import com.xuelang.pipeline.artifact.app.resource.request.NgacAssociateXO;
//import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
//import org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException;
//import org.springframework.cloud.openfeign.FallbackFactory;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.util.concurrent.TimeoutException;
//
///**
// * 系统权限服务fegin调用失败回调实现类
// *
// * @author xiwen.zxg
// * @since 2024/5/15
// */
//@Slf4j
//@Service
//public class SysNgacServiceFallbackImpl implements FallbackFactory<SysNgacService> {
//
//
//    @Override
//    public SysNgacService create(Throwable throwable) {
//        String fallReason = throwable.getMessage();
//        if (throwable instanceof TimeoutException) {
//            fallReason = "Socket connect timeout.";
//        } else if (throwable instanceof NoFallbackAvailableException) {
//            fallReason = "Bad Request.";
//        } else if (throwable instanceof RuntimeException) {
//            fallReason = "Runtime exception";
//        }
//
//        final String returnFallReason = fallReason;
//        final ApiResult apiResult = ApiResult.fail("worker返回异常：" + returnFallReason);
//        log.error("调用fegin数据接口失败。接口名称:{}；失败原因:{}", this.getClass().getName(), fallReason);
//        return new SysNgacService() {
//
//            @Override
//            public ApiResult<NgacAssociateXO> addNgacPermission(NgacAssociateXO ngacAssociateXO) {
//                return apiResult;
//            }
//
//            @Override
//            public ApiResult<Boolean> removeNgacAssociate(NgacAssociateXO ngacAssociateXO) {
//                return apiResult;
//            }
//        };
//    }
//
//}
